import request from 'utils/request'
// 定义 请求 分类的model
const fetchCates = (params = {}) => request.get('/shop/goods/category/all', { params })
// 请求首页轮播
const fetchHomeBanner = (params = {}) => request.get('/banner/list', { params })
// 获取商品
const fetchItems = (params = {}) => request.post('/shop/goods/list/v2', params)
// 获取商品分类
const fetchItemDetail = (id) => request.get('/shop/goods/detail', {
  params: {
    id
  }
})
// 用户注册
const register = (params = {}) => request.post('/user/username/register', params)
// 用户登录
const doLogin = (params = {}) => request.post('/user/username/login', params)
// 获取购物车
const fetchCartItems = (params = {}) => request.get('/shopping-cart/info', { params })
// 添加购物车
const addCart = (params = {}) => request.post('/shopping-cart/add', params)
const setByNumber = (params = {}) => request.post('/shopping-cart/modifyNumber', params)
const switchCheck = (params = {}) => request.post('/shopping-cart/select', params)
const delCartItem = (params = {}) => request.post('/shopping-cart/remove', params)
// 新增收货人列表
const addContact = (params = {}) => request.post('/user/shipping-address/add', params)
// 获取收货人列表
const fetchContacts = (params = {}) => request.post('/user/shipping-address/list/v2', params)
// 修改联系人
const Updatecontact = (params = {}) => request.post('/user/shipping-address/update', params)
// 获取联系人
const fetchContactInfo = (params = {}) => request.get('/user/shipping-address/detail/v2', { params })
// 删除联系人地址
const deleteContact = (params = {}) => request.post('/user/shipping-address/delete', params)
// 获取默认联系人
const fetchDefaultContact = (params = {}) => request.get('/user/shipping-address/default/v2', { params })
export {
  fetchCates,
  fetchHomeBanner,
  fetchItems,
  fetchItemDetail,
  fetchCartItems,
  register,
  doLogin,
  addCart,
  setByNumber,
  switchCheck,
  delCartItem,
  addContact,
  fetchContacts,
  Updatecontact,
  fetchContactInfo,
  deleteContact,
  fetchDefaultContact
}
